// 查看图形详细信息
import React from 'react';
import { Modal } from 'antd';
import ChartsTypeMap from 'src/pages/AnalyseManage/Components/ChartsType';
import styles from './index.module.scss';
import ChartsBase from '../components/ChartsBase';

interface Iprops {
	modalVisible: boolean;
	handleCancel: Function;
	data: any
}

const ViewChart = ( props: Iprops ) => {

	const handleCancel = () => {
		props.handleCancel();
	};

	const { data } = props;

	return (
		<Modal
			okText={'确定'}
			visible={props.modalVisible}
			cancelText={'取消'}
			onCancel={handleCancel}
			onOk={handleCancel}
			title='图形详细信息'
			footer={
				[] // 设置footer为空，去掉 取消 确定默认按钮
			}
			className={styles.view_modal}
		>
			<ChartsBase config={data.content.style}>
				{ChartsTypeMap( data.content.type, {
					config: data.content,
					key: data.content.key,
					id: data.content.key,
					chartLayout: { w: 0, h: 0 }		//	图形组件默认属性
				} )}
			</ChartsBase>
		</Modal>
	);
};

export default React.memo( ViewChart );
